﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR406Response", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR406Response))]
    public class RR406ResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR406Response clazz;
        
        public RR406ResponseSerializer(IRR406Response clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Isikukood");
            if (clazz.Isikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikupnimi");
            if (clazz.Isikupnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikupnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikupnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuenimi");
            if (clazz.Isikuenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikusynnikuup");
            if (clazz.Isikusynnikuup!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikusynnikuup))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikusynnikuup");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikusurmakuup");
            if (clazz.Isikusurmakuup!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikusurmakuup))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikusurmakuup");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikudoknr");
            if (clazz.Isikudoknr!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikudoknr))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikudoknr");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikudokasutus");
            if (clazz.Isikudokasutus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikudokasutus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikudokasutus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ElukohaEHAK");
            if (clazz.ElukohaEHAK!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ElukohaEHAK))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ElukohaEHAK");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Elukohttekst");
            if (clazz.Elukohttekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Elukohttekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Elukohttekst");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("AvaldajaDokumendil");
            if (clazz.AvaldajaDokumendil!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AvaldajaDokumendil))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : AvaldajaDokumendil");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Info");
            if (clazz.Info!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Info))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Info");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Veakood");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Veakood))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("Veatekst");
            if (clazz.Veatekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Veatekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Veatekst");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Isikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>Isikukood");
                }
                clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikukood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>Isikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikupnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>Isikupnimi");
                }
                clazz.Isikupnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikupnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>Isikupnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>Isikuenimi");
                }
                clazz.Isikuenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>Isikuenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikusynnikuup") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>Isikusynnikuup");
                }
                clazz.Isikusynnikuup = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikusynnikuup")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>Isikusynnikuup", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikusurmakuup") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>Isikusurmakuup");
                }
                clazz.Isikusurmakuup = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikusurmakuup")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>Isikusurmakuup", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikudoknr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>Isikudoknr");
                }
                clazz.Isikudoknr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikudoknr")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>Isikudoknr", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikudokasutus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>Isikudokasutus");
                }
                clazz.Isikudokasutus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikudokasutus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>Isikudokasutus", Reader.LocalName);
            }
            if (Reader.LocalName=="ElukohaEHAK") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>ElukohaEHAK");
                }
                clazz.ElukohaEHAK = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ElukohaEHAK")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>ElukohaEHAK", Reader.LocalName);
            }
            if (Reader.LocalName=="Elukohttekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>Elukohttekst");
                }
                clazz.Elukohttekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Elukohttekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>Elukohttekst", Reader.LocalName);
            }
            if (Reader.LocalName=="AvaldajaDokumendil") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>AvaldajaDokumendil");
                }
                clazz.AvaldajaDokumendil = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("AvaldajaDokumendil")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>AvaldajaDokumendil", Reader.LocalName);
            }
            if (Reader.LocalName=="Info") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>Info");
                }
                clazz.Info = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Info")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>Info", Reader.LocalName);
            }
            if (Reader.LocalName=="Veakood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>Veakood");
                }
                clazz.Veakood = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("Veakood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>Veakood", Reader.LocalName);
            }
            if (Reader.LocalName=="Veatekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR406Response>Veatekst");
                }
                clazz.Veatekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Veatekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR406Response>Veatekst", Reader.LocalName);
            }
        }
    }
}
